#include <vector>
#include <stack>

using namespace std;

class Solution
{
public:
    bool IsPopOrder(vector<int> pushV, vector<int> popV)
    {
        stack<int> tmp;
        int j = 0;
        for (int i = 0; i < pushV.size();++i)
        {
            tmp.push(pushV[i]);
            while (!tmp.empty() && popV[j] == tmp.top())
            {
                tmp.pop();
                j++;
            } 
        }
        return tmp.empty();
    }
};